<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        function Student(name, age, sno) {
            this.name = name
            this.age = age
            this.sno = sno
            // this.running = function () {
            //     console.log(this.name, '在跑步');
            // }
            // this.eating = function () {
            //     console.log(this.name, '在吃饭');
            // }
            // this.studying = function () {
            //     console.log(this.name, '在学习');
            // }
        }
        // 这样操作会创造很多个函数  当然这些函数操作一样的 那就没有必要
        // 由于函数的显示原型会赋值给对象的[[prototype]] 而prototype只有一个 利用这个原理
        Student.prototype.running = function () {
            console.log(this.name, '在跑步');
        }
        var s1 = new Student('lyy', 18, 100)
        var s2 = new Student('gsy', 18, 200)
        var s3 = new Student('fff', 18, 300)
        console.log(s1.running === s2.running);
        s1.running(); s2.running();s3.running()
    </script>
</body>

</html>